/*
	Copyright (C) 2004 Chris Rickard
	http://www12.brinkster.com/chrisrickard/

	This file is part of cr:DateEdit
	http://www12.brinkster.com/chrisrickard/development/DateEdit

    cr:DateEdit is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    cr:DateEdit is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with cr:DateEdit; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/


// 	This is the "include file". It does all the work of declaring the cr namespace, importing the htc,
//	linking the default stylesheet, and setting the path variable so the htc knows where itself lives.
//	You should always have a script tag pointing to this file instead of trying to set up the element
//	behavior yourself.
//	See the help for examples on how to do this.

function _WriteDateEditIncludeStatements_()
{
	var dePath;
	var thisScriptPath	= String(document.scripts[document.scripts.length-1].src).replace(/\\/g,"/");

	var lastSlashPos = thisScriptPath.lastIndexOf("/");

	if(lastSlashPos == -1)
		dePath = "";
	else
		dePath = thisScriptPath.substr(0,lastSlashPos) + "/";

	var crns = null;
	for(var i=0;i<document.namespaces.length;i++)
	{
		var ns = document.namespaces[i];
		if(ns.name == "cr")
		{
			crns = ns;
			break;
		}
	}
	
	if(crns == null)
		crns = document.namespaces.add("cr","http://www12.brinkster.com/chrisrickard/");
	
	document.write("<?import namespace='cr' implementation='"  + dePath + "src/dateedit.htc" + "'?>");
	crns.doImport(dePath + "src/dateedit.htc");	
	
	document.write("<link rel='stylesheet' type='text/css' href='" + dePath + "src/dateedit.css' />");
	window._dePath_ = dePath;
}

_WriteDateEditIncludeStatements_();
